package net.hn.hnms.biz.meeting.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.hn.hnms.biz.meeting.domain.MeetingRoom;
import net.hn.hnms.biz.meeting.vo.MeetingRoomVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface MeetingRoomMapper extends BaseMapper<MeetingRoom> {


//    @Select("<script>" +
//            " select wpp.water_supply_company_id waterSupplyCompanyId,wpp.water_place_id waterPlaceId,wpp.water_place_name waterPlaceName, wpp.water_unit_price waterUnitPrice," +
//            " wsc.water_supply_company_name waterSupplyCompanyName,wpp.create_time createTime from water_place_price wpp " +
//            " LEFT JOIN water_supply_company wsc on wpp.water_supply_company_id = wsc.water_supply_company_id " +
//            " where wpp.del_flag = '0'  " +
//            " <if test='query.waterPlaceName != null and query.waterPlaceName != \"\" '> "+
//            " and wpp.water_place_name = #{query.waterPlaceName} " +
//            " </if>"+
//            " order by wpp.create_time desc </script>")
//    @Select("<script>" +" select me.meeting_room_type,me.meeting_room_name,me.meeting_room_address,me.capacity,me.state from hygl.meeting_room me  " +
//            "where me.del_flag = '0' " +
//            " <if test='query.meetingRoomName != null and query.meetingRoomName != \"\" '> "+
//            " and me.meeting_room_name = #{query.meetingRoomName} " +
//            " </if>"+
//            " <if test='query.meetingRoomAddress != null and query.meetingRoomAddress != \"\" '> "+
//            " and me.meeting_room_address like concat('%',#{query.meetingRoomAddress},'%') " +
//            " </if>"+
//            " <if test='query.meetingRoomType != null and query.meetingRoomType != \"\" '> "+
//            " and me.meeting_room_type = #{query.meetingRoomType} " +
//            " </if>"+
//            "   order by me.create_time desc  "+"</script>" )
//      iLIKE '%人民%'
//    Page<MeetingRoomVo> selectPageList(Page<Object> build, @Param("query") MeetingRoomReq query);

    @Update("<script>" +
            " update  hygl.meeting_room set del_flag = '1' " +
            " where meeting_room_id in" +
            " <foreach collection=\"list\" item=\"value\" separator=\",\" open=\"(\" close=\")\">\n" +
            "#{value}" +
            "</foreach>" +
            "</script>")
    void updateDeleteByIds(@Param("list") List<String> list);


    @Select("<script>"+
            "select a.meeting_room_id,a.meeting_room_name,a.capacity,a.meeting_room_type,a.meeting_room_address,a.remarks,a.state,b.meeting_name,b.meeting_date , b.start_time,b.end_time  from "+
            " (select mr.meeting_room_id,mr.meeting_room_name, mr.capacity, mr.meeting_room_type, mr.meeting_room_address, mr.remarks, mr.state from meeting_room mr where mr.state = '1'" +
            " <if test='mineCode != null and mineCode != \"\" and companyCode!= null and companyCode != \"\" '> "+
            " and (mr.mine_code = #{mineCode} or mr.company_code = #{companyCode}) " +
            " </if>"+
            " and mr.del_flag "+
            " ='0')  a left join  "+
            " (select meeting_room_id,mi.meeting_name, mi.meeting_date , mi.start_time,mi.end_time  from meeting_info mi where mi.del_flag='0' and mi.status !='2' and mi.meeting_date = #{query}" +
            " <if test='mineCode != null and mineCode != \"\" and companyCode!= null and companyCode != \"\" '> "+
            " and ( mi.mine_code = #{mineCode} or mi.company_code = #{companyCode} )" +
            " </if>"+
            " ) b on a.meeting_room_id =b.meeting_room_id  "
            +"</script>")
    List<MeetingRoomVo> selectReservePageList(@Param("query") Date dateTime, @Param("mineCode") String mineCode, @Param("companyCode") String companyCode);

}
